#ifndef _XX_YY_BMOCK_LOGFILE
#define _XX_YY_BMOCK_LOGFILE

#include <string>
#include <fstream>

#ifndef BMOCK_LOG_FILENAME
#define BMOCK_LOG_FILENAME "bmock_logfile.txt"
#endif

#ifdef BMOCK_LOG_TO_STDOUT
#define __BMOCK_LOG_TO_STDOUT true
#else
#define __BMOCK_LOG_TO_STDOUT false
#endif

namespace bmock {
	struct bmock_logfile {
		static bmock_logfile* instance() {
			if (instance_ == NULL) {
				instance_ = new bmock_logfile(BMOCK_LOG_FILENAME, __BMOCK_LOG_TO_STDOUT);
			}
			return instance_;
		}

		void add_to_log(const std::string& str);

	private:
		std::ofstream ofile_;
		bool log_to_stdout_;

	private:
		struct killer {
			~killer();
		};

	private:
		bmock_logfile(const std::string& filename, bool log_to_stdout);
		~bmock_logfile();
		bmock_logfile(const bmock_logfile&) {};
		bmock_logfile& operator=(const bmock_logfile&) { return *this; };

	private:
		friend killer::~killer();
		static killer killer_instance_;
		static bmock_logfile* instance_;
	};
}

#endif
